# 
import unittest
from Pid import *
from TallyPid import *

class TallyPidTests(unittest.TestCase):
    def setUp(self):
        return

    def testFailOnBadFilename(self):
# see
# http://stackoverflow.com/questions/88325/how-do-i-unit-test-an-init-method-of-a-python-class-with-assertraises
        filename=''
#        self.assertRaises(NameError, TallyPid.__init__, filename)
#        self.assertRaises(NameError, TallyPid(filename))
        self.failUnlessRaises(NameError, TallyPid, filename)

    def testDontFindPidInBlankTally(self):
        filename='blank_tally.xls'
        blanktally=TallyPid(filename)
        pid=Pid(700107557)
        self.failIf(blanktally.hasPid(pid))

    def testFindPidInTally(self):
        # ASSERT: '700107557' is the first string in tally.xls.0
        filename='tally.xls'
        pid=Pid('700107557')
        tally=TallyPid(filename)
        self.failUnless(tally.hasPid(pid))

    def suite():
        suite = unittest.TestSuite()
        suite.addTest(unittest.makeSuite(TallyPidTests))
        return suite

def main():
    unittest.main()

if __name__ == '__main__':
    main()
